package com.repair.file.config;

import com.repair.file.service.OssService;
import com.repair.file.service.impl.OssServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author chunyu
 * @since 2024/9/27,20:46
 */
@Configuration
@EnableConfigurationProperties(OssProperties.class)
public class OssConfig {

    @Autowired
    private OssProperties ossProperties;

    @Bean
    public OssService ossService() {
        OssServiceImpl ossService = new OssServiceImpl();
        ossService.setEndpoint(ossProperties.getEndpoint());
        ossService.setAccessKeyId(ossProperties.getAccessKeyId());
        ossService.setAccessKeySecret(ossProperties.getAccessKeySecret());
        ossService.setBucketName(ossProperties.getBucketName());
        return ossService;
    }

}
